<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="&amp;#x524D;&amp;#x8A00;   &amp;#x4E4B;&amp;#x524D;&amp;#x5199;&amp;#x8FC7;&amp;#x4E86;Facebook&amp;#x767B;&amp;#x5F55;Google&amp;#x767B;&amp;#x5F55;&amp;#xFF0C;&amp;#x90A3;&amp;#x4E48;Google&amp;#x652F;&amp;#x4ED8;&amp;#x80FD;&amp;#x9519;&amp;#x8FC7;&amp;#x5417;&amp;#xFF1F;&amp;#x5F53;&amp;">
<meta property="og:type" content="article">
<meta property="og:title" content="Android Google应用内支付">
<meta property="og:url" content="http://yoursite.com/2019/08/21/Android-Google应用内支付/index.html">
<meta property="og:site_name" content="Silence潇湘夜雨">
<meta property="og:description" content="&amp;#x524D;&amp;#x8A00;   &amp;#x4E4B;&amp;#x524D;&amp;#x5199;&amp;#x8FC7;&amp;#x4E86;Facebook&amp;#x767B;&amp;#x5F55;Google&amp;#x767B;&amp;#x5F55;&amp;#xFF0C;&amp;#x90A3;&amp;#x4E48;Google&amp;#x652F;&amp;#x4ED8;&amp;#x80FD;&amp;#x9519;&amp;#x8FC7;&amp;#x5417;&amp;#xFF1F;&amp;#x5F53;&amp;">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://yoursite.com/2019/08/21/Android-Google应用内支付/1.png">
<meta property="og:updated_time" content="2019-12-06T10:08:13.060Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android Google应用内支付">
<meta name="twitter:description" content="&amp;#x524D;&amp;#x8A00;   &amp;#x4E4B;&amp;#x524D;&amp;#x5199;&amp;#x8FC7;&amp;#x4E86;Facebook&amp;#x767B;&amp;#x5F55;Google&amp;#x767B;&amp;#x5F55;&amp;#xFF0C;&amp;#x90A3;&amp;#x4E48;Google&amp;#x652F;&amp;#x4ED8;&amp;#x80FD;&amp;#x9519;&amp;#x8FC7;&amp;#x5417;&amp;#xFF1F;&amp;#x5F53;&amp;">
<meta name="twitter:image" content="http://yoursite.com/2019/08/21/Android-Google应用内支付/1.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/08/21/Android-Google应用内支付/">





  <title>Android Google应用内支付 | Silence潇湘夜雨</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Silence潇湘夜雨</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Android开发一枚</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home //首页"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user //关于"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags  //标签"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th //分类"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive //归档"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-schedule">
          <a href="/schedule/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar //日程表"></i> <br>
            
            日程表
          </a>
        </li>
      
        
        <li class="menu-item menu-item-sitemap">
          <a href="/sitemap.xml" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap //站点地图"></i> <br>
            
            站点地图
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/21/Android-Google应用内支付/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Silence潇湘夜雨">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Silence潇湘夜雨">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Android Google应用内支付</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-21T14:13:53+08:00">
                2019-08-21
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/支付/" itemprop="url" rel="index">
                    <span itemprop="name">支付</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.2k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  14
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="&#x524D;&#x8A00;"><a href="#&#x524D;&#x8A00;" class="headerlink" title="&#x524D;&#x8A00;"></a>&#x524D;&#x8A00;</h3><p>   &#x4E4B;&#x524D;&#x5199;&#x8FC7;&#x4E86;Facebook&#x767B;&#x5F55;Google&#x767B;&#x5F55;&#xFF0C;&#x90A3;&#x4E48;Google&#x652F;&#x4ED8;&#x80FD;&#x9519;&#x8FC7;&#x5417;&#xFF1F;&#x5F53;&#x7136;&#x662F;&#x4E0D;&#x80FD;&#x7684;&#x4E86;&#x3002;&#x4ECA;&#x5929;&#x6765;&#x8BF4;&#x8BF4;Google&#x652F;&#x4ED8;&#xFF0C;&#x6211;&#x4EEC;&#x8FD9;&#x91CC;&#x53EA;&#x8BF4;&#x96C6;&#x6210;&#x65B9;&#x5F0F;&#xFF0C;&#x914D;&#x7F6E;&#x53EF;&#x4EE5;&#x770B;<a href="https://developer.android.com/google/play/billing/index.html" target="_blank" rel="noopener">Google(&#x5E94;&#x7528;&#x5185;&#x652F;&#x4ED8;)&#x5B98;&#x65B9;&#x6587;&#x6863;</a>&#x3002;</p>
<h3 id="&#x51C6;&#x5907;&#x5DE5;&#x4F5C;"><a href="#&#x51C6;&#x5907;&#x5DE5;&#x4F5C;" class="headerlink" title="&#x51C6;&#x5907;&#x5DE5;&#x4F5C;"></a>&#x51C6;&#x5907;&#x5DE5;&#x4F5C;</h3><p>  &#x8981;&#x96C6;&#x6210;Google&#x652F;&#x4ED8;&#x7684;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x6709;&#x54EA;&#x4E9B;&#x5462;&#xFF1F;</p>
<ul>
<li><p>1&#x3001;&#x624B;&#x673A;&#x4E0A;&#x5B89;&#x88C5;<strong>Google&#x670D;&#x52A1;</strong>(&#x5F53;&#x7136;&#x662F;&#x9488;&#x5BF9;&#x56FD;&#x5185;&#x7684;&#x7528;&#x6237;&#xFF0C;&#x56FD;&#x5916;&#x7684;&#x76F8;&#x4FE1;&#x5927;&#x90E8;&#x5206;&#x90FD;&#x6709;Google&#x670D;&#x52A1;)&#xFF1B;</p>
</li>
<li><p>2&#x3001;&#x4E00;&#x4E2A;&#x7ED1;&#x5B9A;&#x4FE1;&#x7528;&#x5361;&#x7684;Google&#x8D26;&#x53F7;&#xFF1B;</p>
</li>
<li><p>3&#x3001;Google play&#x5BA2;&#x6237;&#x7AEF;&#xFF1B;</p>
</li>
<li><p>4&#x3001;<a href="https://developer.android.google.cn/distribute/console/" target="_blank" rel="noopener">Google play console</a>&#xFF08;<strong>&#x7528;&#x4E8E;&#x914D;&#x7F6E;&#x5E94;&#x7528;&#x5185;&#x5546;&#x54C1;&#x4FE1;&#x606F;</strong>&#xFF09;&#xFF1B;</p>
</li>
<li><p>5&#x3001;&#x79D1;&#x5B66;&#x4E0A;&#x7F51;&#x7684;&#x5DE5;&#x5177;&#x3002;</p>
<h3 id="&#x9996;&#x5148;"><a href="#&#x9996;&#x5148;" class="headerlink" title="&#x9996;&#x5148;"></a>&#x9996;&#x5148;</h3><p>&#x4E0A;&#x9762;&#x7684;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x90FD;&#x505A;&#x597D;&#x4E86;&#x4E4B;&#x540E;&#x9700;&#x8981;&#x5E72;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x5F53;&#x7136;&#x662F;&#x5728;<a href="https://developer.android.com/distribute/console" target="_blank" rel="noopener">Google play console</a>&#x4E0A;&#x914D;&#x7F6E;&#x76F8;&#x5173;&#x5E94;&#x7528;&#x548C;&#x5546;&#x54C1;&#x4FE1;&#x606F;&#x4E86;&#xFF0C;&#x81F3;&#x4E8E;&#x5982;&#x4F55;&#x914D;&#x7F6E;&#x5177;&#x4F53;&#x53EF;&#x4EE5;&#x53C2;&#x8003;<a href="https://blog.csdn.net/alex_my/article/details/82984706#2__8" target="_blank" rel="noopener">Google&#x652F;&#x4ED8;&#x914D;&#x7F6E;</a>&#x3002;</p>
</li>
<li><p>1&#x3001;&#x652F;&#x4ED8;&#x6D41;&#x7A0B;&#x8BF4;&#x660E;<br>&#x5173;&#x4E8E;Google&#x652F;&#x4ED8;&#x7684;&#x6D41;&#x7A0B;&#x8BF4;&#x660E;&#xFF1A;<br>1&gt;&#x524D;&#x63D0;&#x6761;&#x4EF6;</p>
<pre><code>1&#x3001;&#x68C0;&#x67E5;&#x4F60;&#x7684;&#x5305;&#x540D;&#x548C;&#x7B7E;&#x540D;&#x6587;&#x4EF6;&#x662F;&#x5426;&#x548C;Google Console &#x4E0A;&#x9762;&#x4E0A;&#x4F20;&#x7684;apk&#x5305;&#x662F;&#x5426;&#x4E00;&#x81F4;
2&#x3001;&#x68C0;&#x67E5;&#x7248;&#x672C;&#x53F7;&#x662F;&#x5426;&#x548C;Google console&#x53D1;&#x5E03;&#x7684;apk&#x7248;&#x672C;&#x662F;&#x5426;&#x4E00;&#x81F4;
3&#x3001;&#x68C0;&#x67E5;&#x4F60;&#x662F;&#x5426;&#x53EF;&#x4EE5;&#x8D2D;&#x4E70;&#xFF0C;&#x662F;&#x5426;&#x7ED1;&#x5B9A;&#x4E86;&#x94F6;&#x884C;&#x5361;&#xFF0C;&#x624B;&#x673A;&#x652F;&#x4E0D;&#x652F;&#x6301;Google&#x652F;&#x4ED8;&#xFF0C;&#x624B;&#x673A;&#x662F;&#x5426;&#x6709;Google&#x670D;&#x52A1;</code></pre><p>2&gt;&#x652F;&#x4ED8;&#x6D41;&#x7A0B;</p>
<pre><code>1&#x3001;&#x7B2C;&#x4E00;&#x6B65;&#xFF0C;&#x521D;&#x59CB;&#x5316;Google&#x652F;&#x4ED8;
2&#x3001;&#x7B2C;&#x4E8C;&#x6B65;&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&#x540E;&#x8C03;&#x7528;&#x67E5;&#x8BE2;&#x8D2D;&#x4E70;&#x7684;&#x5546;&#x54C1;&#x64CD;&#x4F5C;&#xFF0C;&#x67E5;&#x8BE2;&#x6210;&#x529F;&#x8C03;&#x7528;&#x6D88;&#x8017;&#x64CD;&#x4F5C;&#xFF0C;&#x9632;&#x6B62;&#x4E0D;&#x80FD;&#x8D2D;&#x4E70;&#x7684;&#x60C5; &#x51B5;&#x53D1;&#x751F;
3&#x3001;&#x7B2C;&#x4E09;&#x6B65;&#xFF0C;&#x751F;&#x6210;&#x8BA2;&#x5355;&#x53F7;&#x8FDB;&#x884C;&#x8D2D;&#x4E70;&#x64CD;&#x4F5C;
4&#x3001;&#x7B2C;&#x56DB;&#x6B65;&#xFF0C;&#x8D2D;&#x4E70;&#x6210;&#x529F;&#x540E;&#x518D;&#x6B21;&#x8C03;&#x7528;&#x4E00;&#x6B21;&#x6D88;&#x8017;&#x64CD;&#x4F5C;&#xFF08;&#x4E3A;&#x4E86;&#x4E0B;&#x6B21;&#x8D2D;&#x4E70;&#x53EF;&#x4EE5;&#x6210;&#x529F;&#xFF09;
5&#x3001;&#x7B2C;&#x4E94;&#x6B65;&#xFF0C;&#x62FF;&#x5230;Google&#x652F;&#x4ED8;&#x8FD4;&#x56DE;&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;&#xFF0C;&#x5728;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x9A8C;&#x8BC1;&#x64CD;&#x4F5C;&#x3002;
6&#x3001;&#x7B2C;&#x516D;&#x6B65;&#xFF0C;&#x670D;&#x52A1;&#x5668;&#x62FF;&#x5230;&#x4F60;&#x4E0A;&#x4F20;&#x7684;&#x76F8;&#x5173;&#x4FE1;&#x606F;&#x548C;Google&#x652F;&#x4ED8;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#x9A8C;&#x8BC1;&#xFF0C;&#x9A8C;&#x8BC1;&#x6210;&#x529F;&#x540E;Google&#x53D1;&#x8D27;&#xFF0C;&#x670D;&#x52A1;&#x5668;&#x7ED9;&#x4F60;&#x8FD4;&#x56DE;&#x76F8;&#x5173;&#x4FE1;&#x606F;</code></pre></li>
<li><p>2&#x3001;&#x96C6;&#x6210;&#x5DE5;&#x4F5C;<br>  &#x9996;&#x5148;&#x5728;AndroidManifest&#x6587;&#x4EF6;&#x4E2D;&#x52A0;&#x5165;&#x652F;&#x4ED8;&#x6743;&#x9650;&#x548C;&#x7248;&#x672C;</p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;uses-permission android:name=<span class="string">&quot;com.android.vending.BILLING&quot;</span>/&gt;</span><br><span class="line"><span class="comment">//&#x5728;application&#x7684;&#x8282;&#x70B9;&#x4E0B;&#x6DFB;&#x52A0;</span></span><br><span class="line">&lt;meta-data</span><br><span class="line">      android:name=<span class="string">&quot;com.google.android.gms.vision.DEPENDENCIES&quot;</span></span><br><span class="line">      android:value=<span class="string">&quot;face&quot;</span> /&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>3&#x3001;&#x590D;&#x5236;Google&#x652F;&#x4ED8;&#x7684;<a href="https://gitee.com/1032200695/google_payment_documents" target="_blank" rel="noopener">aidl&#x6587;&#x4EF6;&#x548C;util&#x5305;</a>&#x4E2D;&#x7684;&#x5404;&#x79CD;&#x6587;&#x4EF6;</li>
</ul>
<p><img src="/2019/08/21/Android-Google&#x5E94;&#x7528;&#x5185;&#x652F;&#x4ED8;/1.png" alt="Google&#x652F;&#x4ED8;&#x9700;&#x8981;&#x7684;&#x6587;&#x4EF6;"></p>
<h3 id="&#x5176;&#x6B21;"><a href="#&#x5176;&#x6B21;" class="headerlink" title="&#x5176;&#x6B21;"></a>&#x5176;&#x6B21;</h3><p>   Google&#x652F;&#x4ED8;&#x7BA1;&#x7406;&#x7C7B;&#x7684;&#x521B;&#x5EFA;&#xFF08;&#x652F;&#x4ED8;&#x5C01;&#x88C5;&#x6210;&#x4E00;&#x4E2A;&#x5DE5;&#x5177;&#x7C7B;&#xFF09;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">GooglePlayManager</span> </span>{</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String TAG = GooglePlayManager.class.getSimpleName();</span><br><span class="line"></span><br><span class="line"><span class="meta">@SuppressLint</span>(<span class="string">&quot;StaticFieldLeak&quot;</span>)</span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> IabHelper mHelper;</span><br><span class="line"><span class="comment">//&#x662F;&#x5426;&#x521D;&#x59CB;&#x5316;</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">boolean</span> mSetupDone = <span class="keyword">false</span>;</span><br><span class="line"><span class="comment">//&#x516C;&#x94A5;</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> String mPublicKey;</span><br><span class="line"><span class="comment">//&#x8BA2;&#x5355;&#x53F7;</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> String payload;</span><br><span class="line">  <span class="comment">//&#x5546;&#x54C1;&#x96C6;&#x5408;</span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> List&lt;String&gt; mGoodsList = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x521D;&#x59CB;&#x5316;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> context   &#x4E0A;&#x4E0B;&#x6587;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> publicKey &#x516C;&#x94A5;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> productID &#x5546;&#x54C1;ID</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> goodsList &#x5546;&#x54C1;&#x96C6;&#x5408;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> mListener &#x63A5;&#x53E3;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">init</span><span class="params">(<span class="keyword">final</span> Context context, String publicKey, <span class="keyword">final</span> String productID,</span></span></span><br><span class="line"><span class="function"><span class="params">                           <span class="keyword">final</span> OnGoogleInitListener mListener)</span> </span>{</span><br><span class="line">    mPublicKey = publicKey;</span><br><span class="line">    <span class="comment">//&#x521B;&#x5EFA;&#x8C37;&#x6B4C;&#x5E2E;&#x52A9;&#x7C7B;</span></span><br><span class="line">    mHelper = <span class="keyword">new</span> IabHelper(context, publicKey);</span><br><span class="line">    mHelper.enableDebugLogging(<span class="keyword">true</span>);</span><br><span class="line">    mHelper.startSetup(<span class="keyword">new</span> IabHelper.OnIabSetupFinishedListener() {</span><br><span class="line">        <span class="meta">@Override</span></span><br><span class="line">        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onIabSetupFinished</span><span class="params">(IabResult result)</span> </span>{</span><br><span class="line">            <span class="keyword">if</span> (!result.isSuccess()) {</span><br><span class="line">                mListener.onGoogleInitFailed(result.getMessage());</span><br><span class="line">                mSetupDone = <span class="keyword">false</span>;</span><br><span class="line">            } <span class="keyword">else</span> {</span><br><span class="line">                mSetupDone = <span class="keyword">true</span>;</span><br><span class="line">                mListener.onGoogleInitSuccess(<span class="string">&quot;init Success&quot;</span>);</span><br><span class="line">                <span class="comment">//getLTOrderID(LTAppID, LTAppKey,gid, packageId, params);</span></span><br><span class="line">                <span class="keyword">try</span> {</span><br><span class="line">                    mHelper.queryInventoryAsync(<span class="keyword">true</span>, <span class="keyword">null</span>, <span class="keyword">null</span>,</span><br><span class="line">                            <span class="keyword">new</span> IabHelper.QueryInventoryFinishedListener() {</span><br><span class="line">                                <span class="meta">@Override</span></span><br><span class="line">                                <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onQueryInventoryFinished</span><span class="params">(IabResult result, Inventory inv)</span> </span>{</span><br><span class="line">                                    <span class="keyword">if</span> (inv != <span class="keyword">null</span> &amp;&amp; inv.getAllPurchases() != <span class="keyword">null</span></span><br><span class="line">                                            &amp;&amp; inv.getAllPurchases().size() &gt; <span class="number">0</span>) {</span><br><span class="line">                                        mGoodsList = getGoodsList(inv.getAllPurchases());</span><br><span class="line">                                    }</span><br><span class="line">                                    <span class="keyword">if</span> (result != <span class="keyword">null</span> &amp;&amp; inv != <span class="keyword">null</span>) {</span><br><span class="line">                                        <span class="keyword">if</span> (result.isSuccess() &amp;&amp; inv.getAllPurchases() != <span class="keyword">null</span></span><br><span class="line">                                                &amp;&amp; inv.getAllPurchases().size() &gt; <span class="number">0</span>) {</span><br><span class="line">                                            <span class="comment">//&#x6D88;&#x8D39;, &#x5E76;&#x4E0B;&#x4E00;&#x6B65;, &#x8FD9;&#x91CC;Demo&#x91CC;&#x9762;&#x6211;&#x6CA1;&#x505A;&#x63D0;&#x793A;,&#x5C06;&#x8D2D;&#x4E70;&#x4E86;,&#x4F46;&#x662F;&#x6CA1;&#x6D88;&#x8D39; </span></span><br><span class="line">                                            <span class="comment">// &#x6389;&#x7684;&#x5546;&#x54C1;&#x76F4;&#x63A5;&#x6D88;&#x8D39;&#x6389;, &#x6B63;&#x5E38;&#x5E94;&#x8BE5;</span></span><br><span class="line">                                            <span class="comment">//&#x7ED9;&#x7528;&#x6237;&#x4E00;&#x4E2A;&#x63D0;&#x793A;,&#x5B58;&#x5728;&#x672A;&#x5B8C;&#x6210;&#x7684;&#x652F;&#x4ED8;&#x8BA2;&#x5355;,&#x662F;&#x5426;&#x5B8C;&#x6210;&#x652F;&#x4ED8;</span></span><br><span class="line">                                            <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; inv.getAllPurchases().size(); i++) {</span><br><span class="line">                                                consumeProduct2(inv.getAllPurchases().get(i));</span><br><span class="line">                                            }</span><br><span class="line"></span><br><span class="line">                                        }</span><br><span class="line">                                    }</span><br><span class="line">                                }</span><br><span class="line">                            });</span><br><span class="line">                } <span class="keyword">catch</span> (IabHelper.IabAsyncInProgressException e) {</span><br><span class="line">                    e.printStackTrace();</span><br><span class="line">                }</span><br><span class="line">            }</span><br><span class="line">        }</span><br><span class="line">    });</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x6D88;&#x8D39;&#x6389;&#x5546;&#x54C1;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">consumeProduct</span><span class="params">(Purchase purchase)</span> </span>{</span><br><span class="line">    <span class="keyword">try</span> {</span><br><span class="line">        mHelper.consumeAsync(purchase, <span class="keyword">new</span> IabHelper.OnConsumeFinishedListener() {</span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onConsumeFinished</span><span class="params">(Purchase purchase, IabResult result)</span> </span>{</span><br><span class="line">             </span><br><span class="line">        });</span><br><span class="line">    } <span class="keyword">catch</span> (IabHelper.IabAsyncInProgressException e) {</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">    }</span><br><span class="line">}</span><br><span class="line">                             </span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x9A8C;&#x8BC1;&#x8BA2;&#x5355;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">consumeProduct2</span><span class="params">(Purchase purchase)</span> </span>{</span><br><span class="line">    <span class="keyword">try</span> {</span><br><span class="line">        mHelper.consumeAsync(purchase, <span class="keyword">new</span> IabHelper.OnConsumeFinishedListener() {</span><br><span class="line">            <span class="meta">@Override</span></span><br><span class="line">            <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onConsumeFinished</span><span class="params">(Purchase purchase, IabResult result)</span> </span>{</span><br><span class="line">                 <span class="keyword">if</span> (purchase.getToken() != <span class="keyword">null</span> &amp;&amp; purchase.getDeveloperPayload() != <span class="keyword">null</span>) {</span><br><span class="line">                        <span class="comment">//&#x8FD9;&#x91CC;&#x9700;&#x8981;&#x548C;&#x4F60;&#x4EEC;&#x7684;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x5546;&#x91CF;&#x7136;&#x540E;&#x9009;&#x62E9;&#x4E0A;&#x4F20;&#x4EC0;&#x4E48;&#x53C2;&#x6570;&#x8FDB;&#x884C;&#x4E0A;&#x4F20;&#x9A8C;&#x8BC1;         </span></span><br><span class="line">                        upload2server2(purchase.getToken(), purchase.getDeveloperPayload());</span><br><span class="line">                    }</span><br><span class="line">             </span><br><span class="line">        });</span><br><span class="line">    } <span class="keyword">catch</span> (IabHelper.IabAsyncInProgressException e) {</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">    }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x8D2D;&#x4E70;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> context     &#x4E0A;&#x4E0B;&#x6587;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> requestCode &#x8BF7;&#x6C42;&#x7801;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> goodsList   &#x5546;&#x54C1;&#x96C6;&#x5408;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> productID   &#x5546;&#x54C1;ID</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> mListener   &#x63A5;&#x53E3;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">recharge</span><span class="params">(<span class="keyword">final</span> Context context,<span class="keyword">final</span> <span class="keyword">int</span> requestCode,</span></span></span><br><span class="line"><span class="function"><span class="params">                         <span class="keyword">final</span> String productID,Map&lt;String,Object&gt;mParams,</span></span></span><br><span class="line"><span class="function"><span class="params">                            <span class="keyword">final</span> OnGooglePlayResultListener mListener)</span> </span>{</span><br><span class="line">    <span class="keyword">if</span> (mSetupDone) {</span><br><span class="line">     <span class="keyword">if</span> (&#x5224;&#x65AD;&#x662F;&#x5426;&#x767B;&#x5F55;&#x6210;&#x529F;) {</span><br><span class="line">                getLTOrderID(mParams);</span><br><span class="line">                }</span><br><span class="line">         </span><br><span class="line">    } <span class="keyword">else</span> {</span><br><span class="line">        <span class="keyword">if</span> (TextUtils.isEmpty(mPublicKey)) {</span><br><span class="line">            <span class="comment">//&#x521B;&#x5EFA;&#x8C37;&#x6B4C;&#x5E2E;&#x52A9;&#x7C7B;</span></span><br><span class="line">            mHelper = <span class="keyword">new</span> IabHelper(context, mPublicKey);</span><br><span class="line">            mHelper.enableDebugLogging(<span class="keyword">true</span>);</span><br><span class="line">            mHelper.startSetup(<span class="keyword">new</span> IabHelper.OnIabSetupFinishedListener() {</span><br><span class="line">                <span class="meta">@Override</span></span><br><span class="line">                <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onIabSetupFinished</span><span class="params">(IabResult result)</span> </span>{</span><br><span class="line">                    <span class="keyword">if</span> (result.isFailure()) {</span><br><span class="line">                        mSetupDone = <span class="keyword">false</span>;</span><br><span class="line">                    }</span><br><span class="line">                    <span class="keyword">if</span> (result.isSuccess()) {</span><br><span class="line">                        mSetupDone = <span class="keyword">true</span>;</span><br><span class="line">                    }</span><br><span class="line">                }</span><br><span class="line">            });</span><br><span class="line">        }</span><br><span class="line"></span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<p> <strong>&#x63A5;&#x53E3;&#x56DE;&#x8C03;&#x6210;&#x529F;&#x8D70;&#x4E0B;&#x9762;&#x7684;&#x6B65;&#x9AA4;</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> *&#x521B;&#x5EFA;&#x8BA2;&#x5355;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">getLTOrderID</span><span class="params">(Map&lt;String,Object&gt;mParams)</span></span>{</span><br><span class="line">     ...</span><br><span class="line">     ...</span><br><span class="line">     ...</span><br><span class="line">     <span class="keyword">if</span>(success){<span class="comment">//&#x7701;&#x7565;&#x53F7;&#x90A3;&#x91CC;&#x5199;&#x81EA;&#x5DF1;&#x521B;&#x5EFA;&#x8BA2;&#x5355;&#x7684;&#x63A5;&#x53E3;&#x56DE;&#x8C03;</span></span><br><span class="line">      </span><br><span class="line">        <span class="keyword">try</span> {</span><br><span class="line">            <span class="keyword">if</span> (mHelper == <span class="keyword">null</span>) <span class="keyword">return</span>;</span><br><span class="line">            List&lt;String&gt; subSku = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">            mHelper.queryInventoryAsync(<span class="keyword">true</span>, goodsList, subSku,</span><br><span class="line">                    <span class="keyword">new</span> IabHelper.QueryInventoryFinishedListener() {</span><br><span class="line">                        <span class="meta">@Override</span></span><br><span class="line">                        <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onQueryInventoryFinished</span><span class="params">(IabResult result, Inventory inv)</span> </span>{</span><br><span class="line">                           <span class="keyword">if</span> (result != <span class="keyword">null</span>) {</span><br><span class="line">                                <span class="keyword">if</span> (result.isSuccess() &amp;&amp; inv.hasPurchase(productID)) {</span><br><span class="line">                                    <span class="comment">//&#x6D88;&#x8D39;, &#x5E76;&#x4E0B;&#x4E00;&#x6B65;, &#x8FD9;&#x91CC;Demo&#x91CC;&#x9762;&#x6211;&#x6CA1;&#x505A;&#x63D0;&#x793A;,&#x5C06;&#x8D2D;&#x4E70;&#x4E86;,&#x4F46;&#x662F;&#x6CA1;&#x6D88;&#x8D39;&#x6389;&#x7684;&#x5546; </span></span><br><span class="line">                                    <span class="comment">//&#x54C1;&#x76F4;&#x63A5;&#x6D88;&#x8D39;&#x6389;, &#x6B63;&#x5E38;&#x5E94;&#x8BE5;</span></span><br><span class="line">                                    <span class="comment">//&#x7ED9;&#x7528;&#x6237;&#x4E00;&#x4E2A;&#x63D0;&#x793A;,&#x5B58;&#x5728;&#x672A;&#x5B8C;&#x6210;&#x7684;&#x652F;&#x4ED8;&#x8BA2;&#x5355;,&#x662F;&#x5426;&#x5B8C;&#x6210;&#x652F;&#x4ED8;</span></span><br><span class="line">                                    consumeProduct(inv.getPurchase(productID));</span><br><span class="line">                                } <span class="keyword">else</span> {</span><br><span class="line">                                    getProduct((Activity) context, requestCode, productID);</span><br><span class="line">                                }</span><br><span class="line">                            }</span><br><span class="line">                            }</span><br><span class="line">                        }</span><br><span class="line"></span><br><span class="line">                    });</span><br><span class="line">        } <span class="keyword">catch</span> (IabHelper.IabAsyncInProgressException e) {</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        }</span><br><span class="line">}</span><br><span class="line">    </span><br><span class="line">      }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x4EA7;&#x54C1;&#x83B7;&#x53D6;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> context      &#x4E0A;&#x4E0B;&#x6587;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> REQUEST_CODE &#x8BF7;&#x6C42;&#x7801;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> SKU          &#x4EA7;&#x54C1;&#x552F;&#x4E00;id, &#x586B;&#x5199;&#x4F60;&#x81EA;&#x5DF1;&#x6DFB;&#x52A0;&#x7684;&#x5546;&#x54C1;id</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> mListener    &#x56DE;&#x8C03;&#x76D1;&#x542C;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">getProduct</span><span class="params">(<span class="keyword">final</span> Activity context, <span class="keyword">int</span> REQUEST_CODE,</span></span></span><br><span class="line"><span class="function"><span class="params">                               <span class="keyword">final</span> String SKU, <span class="keyword">final</span> OnGooglePlayResultListener mListener)</span> </span>{</span><br><span class="line">    <span class="keyword">if</span> (!TextUtils.isEmpty(payload)) {</span><br><span class="line">        <span class="keyword">try</span> {</span><br><span class="line">            mHelper.launchPurchaseFlow(context, SKU, REQUEST_CODE, <span class="keyword">new</span> IabHelper.OnIabPurchaseFinishedListener() {</span><br><span class="line">                <span class="meta">@Override</span></span><br><span class="line">                <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onIabPurchaseFinished</span><span class="params">(IabResult result, Purchase purchase)</span> </span>{</span><br><span class="line">                    <span class="keyword">if</span> (result.isFailure()) {</span><br><span class="line">                        mListener.onPlayError(result.getMessage());</span><br><span class="line">                        <span class="keyword">return</span>;</span><br><span class="line">                    }</span><br><span class="line">                    mListener.onPlaySuccess(<span class="string">&quot;Purchase successful&quot;</span>);</span><br><span class="line">                    <span class="keyword">if</span> (purchase.getSku().equals(SKU)) {</span><br><span class="line">                        <span class="comment">//&#x8D2D;&#x4E70;&#x6210;&#x529F;&#xFF0C;&#x8C03;&#x7528;&#x6D88;&#x8017;</span></span><br><span class="line">                        consumeProduct(purchase);</span><br><span class="line">                    }</span><br><span class="line">                }</span><br><span class="line">            }, payload);</span><br><span class="line">        } <span class="keyword">catch</span> (IabHelper.IabAsyncInProgressException e) {</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        }</span><br><span class="line">    } <span class="keyword">else</span> {</span><br><span class="line">        mListener.onPlayError(<span class="string">&quot;Order creation failed&quot;</span>);</span><br><span class="line">    }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x56DE;&#x8C03;</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> requestCode     &#x8BF7;&#x6C42;&#x7801;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> resultCode      &#x7ED3;&#x679C;&#x7801;</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@param</span> data            &#x6570;&#x636E;</span></span><br><span class="line"><span class="comment">   </span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">onActivityResult</span><span class="params">( <span class="keyword">int</span> requestCode, <span class="keyword">int</span> resultCode, Intent data, <span class="keyword">int</span> selfRequestCode)</span> </span>{</span><br><span class="line">    <span class="comment">//&#x5C06;&#x56DE;&#x8C03;&#x4EA4;&#x7ED9;&#x5E2E;&#x52A9;&#x7C7B;&#x6765;&#x5904;&#x7406;, &#x5426;&#x5219;&#x4F1A;&#x51FA;&#x73B0;&#x652F;&#x4ED8;&#x6B63;&#x5728;&#x8FDB;&#x884C;&#x7684;&#x9519;&#x8BEF;</span></span><br><span class="line">    <span class="keyword">if</span> (mHelper == <span class="keyword">null</span>) <span class="keyword">return</span>;</span><br><span class="line">    mHelper.handleActivityResult(requestCode, resultCode, data);</span><br><span class="line">    <span class="keyword">if</span> (requestCode == selfRequestCode) {</span><br><span class="line">        <span class="keyword">int</span> responseCode = data.getIntExtra(<span class="string">&quot;RESPONSE_CODE&quot;</span>, <span class="number">0</span>);</span><br><span class="line">        <span class="comment">//&#x8BA2;&#x5355;&#x4FE1;&#x606F;</span></span><br><span class="line">        String purchaseData = data.getStringExtra(<span class="string">&quot;INAPP_PURCHASE_DATA&quot;</span>);</span><br><span class="line">        String dataSignature = data.getStringExtra(<span class="string">&quot;INAPP_DATA_SIGNATURE&quot;</span>);</span><br><span class="line">        <span class="keyword">if</span> (!TextUtils.isEmpty(purchaseData)) {</span><br><span class="line">            GoogleModel googleModel = <span class="keyword">new</span> Gson().fromJson(purchaseData, GoogleModel.class);</span><br><span class="line">            Log.e(TAG, googleModel.getPurchaseToken());</span><br><span class="line">            Map&lt;String, Object&gt; params = <span class="keyword">new</span> WeakHashMap&lt;&gt;();</span><br><span class="line">            params.put(&#x8D2D;&#x4E70;&#x6210;&#x529F;&#x7684;token&#xFF08;&#x5177;&#x4F53;&#x4EE5;&#x81EA;&#x5DF1;&#x670D;&#x52A1;&#x7684;&#x89C4;&#x5B9A;&#x4E3A;&#x51C6;&#xFF09;, googleModel.getPurchaseToken());</span><br><span class="line">            params.put(&#x8BA2;&#x5355;&#x53F7;, payload);</span><br><span class="line">             <span class="comment">//&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x9A8C;&#x8BC1;&#x4E4B;&#x540E;&#x518D;&#x6B21;&#x8C03;&#x7528;&#x6D88;&#x8D39;&#x7528;&#x4E8E;&#x6D88;&#x8017;&#x6389;&#x8D2D;&#x4E70;&#x7684;&#x5546;&#x54C1;</span></span><br><span class="line">            upload2server(xx);</span><br><span class="line">           </span><br><span class="line">        }</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x9A8C;&#x8BC1;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">upload2server</span><span class="params">(xx xx)</span></span>{</span><br><span class="line">    </span><br><span class="line">}</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> *&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x9A8C;&#x8BC1;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">upload2server2</span><span class="params">(xx xx)</span></span>{</span><br><span class="line">     ...</span><br><span class="line">     ...</span><br><span class="line">     ...</span><br><span class="line">     <span class="comment">//&#x9A8C;&#x8BC1;&#x6210;&#x529F;&#x540E;&#x518D;&#x6B21;&#x8C03;&#x7528;&#x8D2D;&#x4E70;&#x65B9;&#x6CD5;</span></span><br><span class="line">        recharge(<span class="keyword">final</span> Context context,<span class="keyword">final</span> <span class="keyword">int</span> requestCode,</span><br><span class="line">                         <span class="keyword">final</span> String productID,Map&lt;String,Object&gt;mParams,</span><br><span class="line">                            <span class="keyword">final</span> OnGooglePlayResultListener mListener)</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x91CA;&#x653E;&#x8D44;&#x6E90;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">release</span><span class="params">()</span> </span>{</span><br><span class="line">    <span class="keyword">if</span> (mHelper != <span class="keyword">null</span>) {</span><br><span class="line">        mHelper.disposeWhenFinished();</span><br><span class="line">    }</span><br><span class="line">    mHelper = <span class="keyword">null</span>;</span><br><span class="line">}</span><br><span class="line"> <span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &#x83B7;&#x53D6;&#x5546;&#x54C1;&#x96C6;&#x5408;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> List&lt;String&gt; <span class="title">getGoodsList</span><span class="params">(</span></span></span><br><span class="line"><span class="function"><span class="params">        List&lt;Purchase&gt; mList)</span> </span>{</span><br><span class="line">    mGoodsList = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; mList.size(); i++) {</span><br><span class="line">        mGoodsList.add(mList.get(i).getSku());</span><br><span class="line">    }</span><br><span class="line">    <span class="keyword">return</span> mGoodsList;</span><br><span class="line">}</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<p><strong>&#x6D41;&#x7A0B;&#x8BF4;&#x660E;:</strong>&#x9996;&#x5148;&#x521D;&#x59CB;&#x5316;Google&#x652F;&#x4ED8;&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&#x540E;&#x67E5;&#x8BE2;&#x662F;&#x5426;&#x6709;&#x672A;&#x6D88;&#x8D39;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x5219;&#x6D88;&#x8D39;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x5219;&#x7EE7;&#x7EED;&#x8C03;&#x7528;&#x8D2D;&#x4E70;&#x529F;&#x80FD;&#x3002;&#x5F53;&#x7136;&#xFF0C;&#x8D2D;&#x4E70;&#x4E4B;&#x524D;&#x9700;&#x8981;&#x521B;&#x5EFA;&#x8BA2;&#x5355;&#xFF0C;&#x4E4B;&#x540E;&#x4F20;&#x5165;Google&#x652F;&#x4ED8;&#x9700;&#x8981;&#x7684;&#x53C2;&#x6570;&#x652F;&#x4ED8;&#x3002;&#x652F;&#x4ED8;&#x6210;&#x529F;&#x540E;&#x5728;onActivityResult&#x65B9;&#x6CD5;&#x91CC;&#x83B7;&#x53D6;&#x5230;Google&#x8FD4;&#x56DE;&#x7684;token&#xFF0C;&#x7136;&#x540E;&#x5230;&#x81EA;&#x5DF1;&#x7684;&#x670D;&#x52A1;&#x5668;&#x505A;&#x9A8C;&#x8BC1;&#x3002;&#x9A8C;&#x8BC1;&#x6210;&#x529F;&#x540E;&#x518D;&#x6B21;&#x8C03;&#x7528;Google&#x7684;&#x6D88;&#x8D39;&#x529F;&#x80FD;&#xFF0C;&#x7528;&#x4E8E;&#x6D88;&#x8017;&#x6B64;&#x6B21;&#x8D2D;&#x4E70;&#x3002;&#x8FD9;&#x4E00;&#x6B65;&#x5343;&#x4E07;&#x4E0D;&#x80FD;&#x7701;&#xFF0C;&#x8981;&#x4E0D;&#x4E0B;&#x6B21;&#x53EF;&#x80FD;&#x5C31;&#x4E0D;&#x80FD;&#x8FDB;&#x884C;&#x8D2D;&#x4E70;&#x4E86;&#x3002;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">GoogleModel</span> </span>{</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span> String packageName;</span><br><span class="line"><span class="keyword">private</span> String productId;</span><br><span class="line"><span class="keyword">private</span> <span class="keyword">long</span> purchaseTime;</span><br><span class="line"><span class="keyword">private</span> <span class="keyword">int</span> purchaseState;</span><br><span class="line"><span class="keyword">private</span> String developerPayload;</span><br><span class="line"><span class="keyword">private</span> String purchaseToken;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getOrderId</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> orderId;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setOrderId</span><span class="params">(String orderId)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.orderId = orderId;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getPackageName</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> packageName;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPackageName</span><span class="params">(String packageName)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.packageName = packageName;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getProductId</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> productId;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setProductId</span><span class="params">(String productId)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.productId = productId;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">long</span> <span class="title">getPurchaseTime</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> purchaseTime;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPurchaseTime</span><span class="params">(<span class="keyword">long</span> purchaseTime)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.purchaseTime = purchaseTime;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">getPurchaseState</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> purchaseState;</span><br><span class="line">  }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPurchaseState</span><span class="params">(<span class="keyword">int</span> purchaseState)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.purchaseState = purchaseState;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getDeveloperPayload</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> developerPayload;</span><br><span class="line">   }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setDeveloperPayload</span><span class="params">(String developerPayload)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.developerPayload = developerPayload;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getPurchaseToken</span><span class="params">()</span> </span>{</span><br><span class="line"><span class="keyword">return</span> purchaseToken;</span><br><span class="line">  }</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPurchaseToken</span><span class="params">(String purchaseToken)</span> </span>{</span><br><span class="line"><span class="keyword">this</span>.purchaseToken = purchaseToken;</span><br><span class="line">    }</span><br><span class="line">   }</span><br></pre></td></tr></table></figure>

<ul>
<li>&#x63A5;&#x53E3;</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> *&#x521D;&#x59CB;&#x5316;&#x63A5;&#x53E3;</span><br><span class="line"> */</span><br><span class="line">public interface OnGoogleInitListener {</span><br><span class="line">    /**</span><br><span class="line">     * &#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;</span><br><span class="line">     *</span><br><span class="line">     * @param success &#x6210;&#x529F;&#x56DE;&#x8C03;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onGoogleInitSuccess(String success);</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * &#x521D;&#x59CB;&#x5316;&#x5931;&#x8D25;&#x56DE;&#x8C03;</span><br><span class="line">     *</span><br><span class="line">     * @param result &#x5931;&#x8D25;&#x56DE;&#x8C03;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onGoogleInitFailed(String result);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> *&#x652F;&#x4ED8;&#x7ED3;&#x679C;&#x63A5;&#x53E3;</span><br><span class="line"> */</span><br><span class="line">public interface OnGoogleResultListener {</span><br><span class="line">    /**</span><br><span class="line">     * Google play &#x8FD4;&#x56DE;&#x4FE1;&#x606F;&#xFF08;&#x6210;&#x529F;&#xFF09;</span><br><span class="line">     *</span><br><span class="line">     * @param result &#x6210;&#x529F;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onResultSuccess(String result);</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * &#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x9519;&#x8BEF;</span><br><span class="line">     *</span><br><span class="line">     * @param ex &#x9519;&#x8BEF;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onResultError(Throwable ex);</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * Google play &#x8FD4;&#x56DE;&#x4FE1;&#x606F;&#xFF08;&#x5931;&#x8D25;&#xFF09;</span><br><span class="line">     *</span><br><span class="line">     * @param failedMsg &#x5931;&#x8D25;&#x5185;&#x5BB9;</span><br><span class="line">     */</span><br><span class="line">    void onResultFailed(String failedMsg);</span><br><span class="line">}</span><br><span class="line">/**</span><br><span class="line"> *&#x521B;&#x5EFA;&#x8BA2;&#x5355;&#x63A5;&#x53E3;</span><br><span class="line"> */</span><br><span class="line">public interface OnCreateOrderListener {</span><br><span class="line"></span><br><span class="line">    void onOrderSuccess(String result);</span><br><span class="line"></span><br><span class="line">    void onOrderFailed(Throwable ex);</span><br><span class="line"></span><br><span class="line">    void onOrderError(String error);</span><br><span class="line">}</span><br><span class="line">/**</span><br><span class="line"> *&#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x7ED3;&#x679C;&#x63A5;&#x53E3;</span><br><span class="line"> */</span><br><span class="line">public interface OnGoogleResultListener {</span><br><span class="line">    /**</span><br><span class="line">     * Google play &#x8FD4;&#x56DE;&#x4FE1;&#x606F;&#xFF08;&#x6210;&#x529F;&#xFF09;</span><br><span class="line">     *</span><br><span class="line">     * @param result &#x6210;&#x529F;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onResultSuccess(String result);</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * &#x4E0A;&#x4F20;&#x5230;&#x670D;&#x52A1;&#x5668;&#x9519;&#x8BEF;</span><br><span class="line">     *</span><br><span class="line">     * @param ex &#x9519;&#x8BEF;&#x4FE1;&#x606F;</span><br><span class="line">     */</span><br><span class="line">    void onResultError(Throwable ex);</span><br><span class="line"></span><br><span class="line">    /**</span><br><span class="line">     * Google play &#x8FD4;&#x56DE;&#x4FE1;&#x606F;&#xFF08;&#x5931;&#x8D25;&#xFF09;</span><br><span class="line">     *</span><br><span class="line">     * @param failedMsg &#x5931;&#x8D25;&#x5185;&#x5BB9;</span><br><span class="line">     */</span><br><span class="line">    void onResultFailed(String failedMsg);</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<h3 id="&#x6700;&#x540E;"><a href="#&#x6700;&#x540E;" class="headerlink" title="&#x6700;&#x540E;"></a>&#x6700;&#x540E;</h3><p> &#x597D;&#x4E86;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;&#x4ECA;&#x5929;&#x7684;Google&#x652F;&#x4ED8;&#x8BF4;&#x660E;&#x4E86;&#xFF0C;&#x5199;&#x7684;&#x4E0D;&#x597D;&#x8FD8;&#x8BF7;&#x8C05;&#x89E3;&#x3002;</p>
<h3 id="&#x611F;&#x8C22;"><a href="#&#x611F;&#x8C22;" class="headerlink" title="&#x611F;&#x8C22;"></a>&#x611F;&#x8C22;</h3><p>   <a href="https://blog.csdn.net/alex_my/article/details/82984706#2__8" target="_blank" rel="noopener">&#x8C37;&#x6B4C;&#x652F;&#x4ED8;&#x9A8C;&#x8BC1; 403&#x9519;&#x8BEF;</a></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/08/21/Android-Google-原生登录/" rel="next" title="Android Google 原生登录">
                <i class="fa fa-chevron-left"></i> Android Google 原生登录
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/08/21/Android-海外应用内支付之ONE-store（韩国支付SDK）集成封装/" rel="prev" title="Android 海外应用内支付之ONE store（韩国支付SDK）集成封装">
                Android 海外应用内支付之ONE store（韩国支付SDK）集成封装 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Silence潇湘夜雨</p>
              <p class="site-description motion-element" itemprop="description">Android开发一枚</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">55</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/muyishuangfeng" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/1e2eec6f972c" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-heartbeat"></i>简书</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://juejin.im/user/58df0abf61ff4b006b115e43" target="_blank" title="掘金">
                      
                        <i class="fa fa-fw fa-star"></i>掘金</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://twitter.com/yangke20792452" target="_blank" title="Twitter">
                      
                        <i class="fa fa-fw fa-twitter"></i>Twitter</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#准备工作"><span class="nav-number">2.</span> <span class="nav-text">准备工作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#首先"><span class="nav-number">3.</span> <span class="nav-text">首先</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#其次"><span class="nav-number">4.</span> <span class="nav-text">其次</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#最后"><span class="nav-number">5.</span> <span class="nav-text">最后</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#感谢"><span class="nav-number">6.</span> <span class="nav-text">感谢</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Silence潇湘夜雨</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">114.8k</span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

  <!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":false},"react":{"opacityDefault":0.5,"opacityOnHover":0.5},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
